﻿using System.Linq;
using System.Net;
using System.Net.Http;

namespace Neo4jConnect.Rest
{
    public static class HttpResponseMessageExtensions
    {
        public static HttpResponseMessage EnsureStatusCode(this HttpResponseMessage responseMessage, params HttpStatusCode[] statuses)
        {
            if (statuses.Contains(responseMessage.StatusCode))
                return responseMessage;

            throw new Neo4jRestException(responseMessage.StatusCode, responseMessage.ReasonPhrase);
        }
    }
}